<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>50-无限循环滚动</title>
    <style>
        *{
            margin:0px;
            padding:0px;
        }
        .container{
            width:600px;
            height:161px;
            border:1px solid #000;
            margin:100px auto;
            overflow:hidden;
        }
        .container>ul{
            list-style:none;
            width:2000px;
            height:161px;
            background-color:#000;
        }
        ul>li img{
            width:400px;
            height:161px;
            /* display:none; */
        }
        ul>li{
            float:left;
        }
    </style>
</head>
<body>
    <div class="container">
        <ul>
            <li><img src="imgs/红米9a.jpg"></li>
            <li><img src="imgs/红米智能电视.webp"></li>
            <li><img src="imgs/红米k30.webp"></li>
            <li><img src="imgs/小米手环5.webp"></li>
            <li><img src="imgs/红米9a.jpg"></li>
            <li><img src="imgs/红米智能电视.webp"></li>
        </ul>
    </div>
    <script src="./js/jquery-1.12.4.js"></script>
    <script>
        //0.定义一个保存单个图片到ul的偏移位
      $(function(){
        var offset =0;
          var timer;
          //1.让图片滚动起来
          function autoPlay(){
            timer = setInterval(function(){
              offset-=10;
              if (offset<=-1600){
                  offset = 0
              }
              $('ul').css('marginLeft',offset);
          },50)};
          autoPlay();
          //2.监听li的移入和移出事件
          $('li').mouseenter(function(){
            //停止定时器
            clearInterval(timer)
            //给除当前之外的li设置蒙版
            $(this).siblings().fadeTo(100,0.5)
            //给当前的li去除蒙版
            $(this).fadeTo(100,1)
          })
          $('li').mouseleave(function(){
            //鼠标移出li之后，继续播放
            autoPlay();
            //给所有li去除蒙版
            $('li').fadeTo(100,1)
          })
      })
    </script>
</body>
</html>